home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / C / GBDK / tst / test.c < prev   
Encoding:
C/C++ Source or Header  |  1996-04-03  |  2.2 KB  |  125 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <graphics.h>
  4. #include "fish.h"
  5.  
  6. void main()
  7. {
  8.   char s[16];
  9.   int i, j, k;
  10.  
  11.   puts("A:text demo");
  12.   puts("B:graphic demo");
  13.  
  14.   i = waitpad(J_A | J_B);
  15.   waitpadup();
  16.  
  17.   if(i == J_A) {
  18.     int i1, i2, i3;
  19.  
  20.     printf("Hello %s\n", "World");
  21.     strcpy(s, "Hello World!");
  22.     reverse(s);
  23.     puts(s);
  24.  
  25.     for(i = 0; i <= 0x10; i++) {
  26.       printn(i, 16);
  27.       putchar(' ');
  28.     }
  29.     putchar(EOL);
  30.  
  31.     for(i = 0; i < 3; i++) {
  32.       switch(i)
  33.         {
  34.         case 0:
  35.           printn(0, 10);
  36.           break;
  37.         case 1:
  38.           printn(1, 10);
  39.         break;
  40.         case 2:
  41.           printn(2, 10);
  42.           break;
  43.         default:
  44.           print("Error");
  45.         break;
  46.         }
  47.       putchar(' ');
  48.     }
  49.     putchar(EOL);
  50.  
  51.     printf("Numbers: %c %d %o %x\n", 'A', 13, 13, 13);
  52.     printf("Enter 3 nb:");
  53.     i = scanf("%d %x %o", &i1, &i2, &i3);
  54.     printf("Result: %d %d %d %d\n", i, i1, i2, i3);
  55.  
  56.     itoa(abs(-234), s);
  57.     puts(s);
  58.     itoa(-234, s);
  59.     puts(s);
  60.     itoa(atoi(s), s);
  61.     puts(s);
  62.  
  63.     strcpy(s, "Hello");
  64.     strcat(s, " World!");
  65.     puts(s);
  66.  
  67.     printn(strlen(s), 10);
  68.     putchar(EOL);
  69.  
  70.     printn(strcmp(s, "Hello Earth!"), 10);
  71.     putchar(' ');
  72.     printn(strcmp(s, "Hello World!"), 10);
  73.     putchar(' ');
  74.     printn(strcmp(s, "Hi World!"), 10);
  75.     putchar(EOL);
  76.  
  77.     printf("Enter nb: ");
  78.     puts(gets(s));
  79.     printf("2 * ");
  80.     print(s);
  81.     printf(" = ");
  82.     puts(itoa(atoi(s) * 2, s));
  83.  
  84.     printf("End of program");
  85.   } else {
  86.     int m = OR;
  87.     int c = BLACK;
  88.  
  89.     i = 50;
  90.     j = 50;
  91.     k = 0;
  92.     while(1) {
  93.       k = waitpad(J_UP | J_DOWN | J_LEFT | J_RIGHT | J_A | J_B | J_START);
  94.       if(k & J_START) {
  95.     break;
  96.       }
  97.       if(k & J_A) {
  98.         m = ++m % 4;
  99.     waitpadup();
  100.       }
  101.       if(k & J_B) {
  102.         c = ++c % 4;
  103.     waitpadup();
  104.       }
  105.      if(k & J_UP)
  106.         j--;
  107.       if(k & J_DOWN)
  108.         j++;
  109.       if(k & J_LEFT)
  110.         i--;
  111.       if(k & J_RIGHT)
  112.         i++;
  113.       if(i >= 0 && i <= 0x7F && j >= 0 && j <= 0x77)
  114.         plot(i, j, c, m);
  115.       i = i < 0 ? 0 : i;
  116.       j = j < 0 ? 0 : j;
  117.       i = i > 0x7F ? 0x7F : i;
  118.       j = j > 0x77 ? 0x77 : j;
  119.       delay(500);
  120.     }
  121.     draw_image(fish_data);
  122.     waitpad(J_START);
  123.   }
  124. }
  125.